home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual Basic 5 / Mastering Microsoft Visual Basic 5.ISO / media / ch04 / v04d025.cc < prev    next >
Text File  |  1997-01-24  |  2KB  |  22 lines

  1. 0, In this demonstration we'll take a look at the run-time errors that can occur in a multi-user situation.
  2. 13,  In this example, we have two instances of an application that will edit records for the Categories table in the Northwind database.
  3. 23, We will use Pessimistic Locking.
  4. 25,  With Pessimistic Locking, our record will be locked when we invoke the Edit method of our recordset.
  5. 33,  In the second instance, when I click the Edit button, we get a run-time error that indicates that our record is currently locked.
  6. 47, With Optimistic Locking, our record will be locked when we update the changes.
  7. 54,  I'll set the second instance of our application to use Optimistic Locking.
  8. 60,  I'll edit the record in the first instance and edit the record in the second instance.
  9. 66,  Notice no run-time error yet.
  10. 71,  However, when I save the changes in the second instance, we get the run-time error that does indeed indicate that the record is currently locked.
  11. 90, Let's set both instances to use Optimistic Locking.
  12. 94,  I can edit both instances of the record.
  13. 98,  I can change the first instance.
  14. 102,  With the Update method of the recordset, our changes take effect just fine.
  15. 108,  And then in the second instance, when I try to change the record here, I'm told that the record has already been changed by some other user, and that my changes have been cancelled.
  16. 122, Let's take a look at the Visual Basic code that traps these run-time errors.
  17. 131,  In the Click event behind the Edit button, we are indeed calling the Edit method of the recordset and we're trapping for error 3260.
  18. 141,  This is the error that indicates that our record is locked by another user.
  19. 148, In the Click event for the Save button, we are using the Update method for the recordset and we're trapping for error 3260, the record lock error, and error 3197.
  20. 162,  This is the error that indicates that our data has been changed by some other user.
  21. 168, It's important to remember when you write multi-user applications to trap for these locking errors that can occur on your database.
  22. 179, END